<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='用户管理',active='users'">
<header th:replace="admin/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="admin/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">用户管理</h4>
                    </div>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th width="8%">账号</th>
                                <th width="8%">邮箱</th>
                                <th width="8%">昵称</th>
                                <th width="10%">注册时间</th>
                                <th width="10%">最后活动时间</th>
                                <th width="8%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="user : ${users.list}">
                                <tr th:cid="${user.uid}">
                                    <td>
                                        <a th:href="@{'/admin/article/'+${user.uid}}" th:text="${user.username}"></a>
                                    </td>
                                    <td><th:block th:text="${user.email}"/></td>
                                    <td><th:block th:text="${user.screenName}"/></td>
                                    <td><th:block th:text="${commons.fmtdate(user.created, 'yyyy-MM-dd HH:mm:ss')}"/></td>
                                    <td>
                                       <!--  <th:block th:if="${user.status == 'publish'}">
                                            <span class="label label-success">已发布</span>
                                        </th:block>
                                       <th:block th:if="${user.status == 'draft'}">
                                           <span class="label label-default">草稿</span>
                                       </th:block> -->
                                    </td>
                                    <td>
                                        <a href="javascript:void(0)" th:onclick="'delPost('+${user.uid}+');'"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-trash-o"></i> <span>删除</span></a>
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                        <div th:replace="comm/macros :: pageAdminNav(${users})"></div>
                    </div>
                </div>
                <div th:replace="admin/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="admin/footer :: footer"></div>
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();
    function delPost(uid) {
    	layer.confirm('确定要删除该用户吗?', {icon: 3, title:'提示'}, function(index){
                tale.post({
                    url : '/admin/users/delete',
                    data: {uid: uid},
                    success: function (result) {
                        if(result && result.success){
                            layer.alert('用户删除成功', function(index){
                                window.location.href = '/admin/users';
                        		  layer.close(index);
                        		});
                        } else {
                            layer.msg(result.msg || '用户删除失败', {icon: 5});
                        }
                    }
                });
                layer.close(index);
		});
        
    }
    /*]]>*/
</script>
</body>
</html>